/*
 * @lc app=leetcode.cn id=41 lang=cpp
 *
 * [41] 缺失的第一个正数
 */
#include "include.h"
// @lc code=start
class Solution {
public:
    int firstMissingPositive(vector<int>& nums) {
        // use nums as hashTable
        // swap nums[i] to nums[ nums[i] ]

        std::unordered_set<int> hashSet;
        for (auto num : nums){
            hashSet.emplace(num);
        }
        for (int i=1;i<=nums.size();i++){
            if (hashSet.find(i) == hashSet.end()){
                return i;
            }
        }
        return nums.size()+1;
    }
};
// @lc code=end

